# _*_ encoding:utf-8 _*_
from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response


class MyPage(PageNumberPagination):
    page_size = 5  # 默认按照10个每页划分
    max_page_size = 3  # 最大每页按照100个划分
    page_query_param = 'page'  # ?page=1
    page_size_query_param = 'pagesize'  # ?pagesize=10

    def get_paginated_response(self, data):
        return Response({
            'count': self.page.paginator.count,
            'results': data,
            'page': self.page.number,
            'pages': self.page.paginator.num_pages,
            'pagesize': self.page_size  # 后端默认每页数量
        })
